//
//  UIImageView+sjkf.swift
//  Employee
//
//  Created by swordjoy on 2017/3/22.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import Foundation
import UIKit
import Kingfisher

extension UIImageView {
  
  func setImage(with urlString: String, placeholder: UIImage? = nil) {
    guard let url = URL(string: urlString) else {
      image = placeholder
      return
    }
    kf.setImage(with: url, placeholder: placeholder)
  }
  
  //
  func setImageMemoryOnly(with urlString: String, placeholder: UIImage? = nil) {
    
    guard let url = URL(string: urlString) else {
      image = placeholder
      return
    }
    
    kf.setImage(with: url, placeholder: placeholder, options: [.cacheMemoryOnly], progressBlock: nil, completionHandler: nil)
    
  }
  
  func setImageCallbackInBackground(with urlString: String, placeholder: UIImage? = nil)  {
    
    guard let url = URL(string: urlString) else {
      image = placeholder
      return
    }
    
    kf.setImage(with: url, placeholder: placeholder, progressBlock: nil, completionHandler: nil)
    
  }
  
}
